<?php
/**
 * User: Administrator
 * Time: 2015/10/27 19:25
 */


function generateXmlFile($filename, $size) {
	$test  = fopen($filename, 'w');
	$start = '<?xml version="1.0" encoding="UTF-8"?><collection>';
	$block = '<cd><title type="hk151">港台明星254</title><artist>刘德华186</artist><year>1995475</year></cd>';
	echo '开始生成xml文件' . PHP_EOL;
	fwrite($test, $start);
	while (true) {
		fwrite($test, $block);
		$current_size = filesize($filename);
		clearstatcache();
		echo $current_size . ' / ' . $size . PHP_EOL;
		if ($current_size > $size) {
			break;
		}
	};
	$end = "  </collection>";
	fwrite($test, $end);
	fclose($test);
	echo 'xml文件生成成功' . PHP_EOL;
}

generateXmlFile('./test.xml',1024*1024*1024);









